package com.lengchangjing.StructuralPatterns.CompositePattern;


import org.apache.commons.lang3.StringUtils;

public class Leaf implements Component{
    @Override
    public void Operaton(int depth) {
        System.out.println(StringUtils.repeat(' ',depth - 2) + "|");
        System.out.println(StringUtils.repeat(' ',depth - 2) + "--" + this.getClass().getSimpleName() + " Operation");
    }

    @Override
    public void Add(Component component) {
        System.out.println("Cannot add to a leaf");
    }

    @Override
    public void Remove(Component component) {
        System.out.println("Cannot remove from a leaf");
    }

    @Override
    public Component GetChild(int i) throws Exception {
        throw new Exception("Cannot get a child from a leaf");
    }
}
